package cn.bigfire.wedesk.util.portsanner;

import cn.bigfire.wedesk.util.NetKit;
import cn.hutool.core.net.NetUtil;
import com.alibaba.fastjson.JSON;
import io.netty.util.NettyRuntime;

public class MainTest {

    public static void main(String[] args) {
        IpPorts ipPorts1 = PortScanner.scanPortUsedByIp(NetUtil.getLocalhostStr());
        IpPorts ipPorts2 = PortScanner.scanPortAlreadyByIp(NetUtil.getLocalhostStr());
        System.out.println(ipPorts1.getPortList().size());
        System.out.println(ipPorts2.getPortList().size());

        System.out.println(JSON.toJSONString(ipPorts1));
        System.out.println(JSON.toJSONString(ipPorts2));
    }

    /**
     * 测试主机，找合适合适的线程数
     */
    public static void findThreadPoolCoreNum(){
//        System.out.printf("cpuNum:%s,netType:%s%n", NettyRuntime.availableProcessors(), NetKit.getNetType());
//        String ip = NetUtil.getLocalhostStr();
//        for (int i = 1; i <= 4; i++) {
//            int num = 1000 * i;
//            IpPorts ipPorts = PortScanner.scanPortByIp(ip, num, Boolean.TRUE);
//            System.out.println(ipPorts.getPortList().size() + " 个," + JSON.toJSONString(ipPorts.getPortList()));
//        }
    }

}

